]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
St: fix parsing of transition-duration values
authorGiovanni Campagna <gcampagna@src.gnome.org>
Tue, 7 Aug 2012 14:20:43 +0000 (16:20 +0200)
committerGiovanni Campagna <gcampagna@src.gnome.org>
Thu, 3 Jan 2013 02:47:58 +0000 (03:47 +0100)
According to css3-transition, transition-duration is expressed
as a time, that is, in seconds or milliseconds. Fix that by
recognizing numbers with units and implicitly converting to
milliseconds after parsing.

https://bugzilla.gnome.org/show_bug.cgi?id=681376

data/theme/gnome-shell.css
src/st/st-theme-node.c
src/st/st-theme-node.h

index 634d4cff43116c20d27fef3bac0f4b346d1bca41..977efa829ab959a91941bbae8bc0148b06040b38 100644 (file)
@@ -359,7 +359,7 @@ StScrollBar StButton#vhandle:active {
     background-gradient-start: rgba(5,5,6,0.1);
     background-gradient-end: rgba(254,254,254,0.1);
     background-gradient-direction: vertical;
-    transition-duration: 300;
+    transition-duration: 300ms;
     box-shadow: inset 0px 2px 4px rgba(0,0,0,0.6);
 }
 
@@ -394,7 +394,7 @@ StScrollBar StButton#vhandle:active {
     color: rgb(64, 64, 64);
     caret-color: rgb(64, 64, 64);
     font-weight: bold;
-    transition-duration: 0;
+    transition-duration: 0ms;
 }
 
 .notification StEntry,
@@ -425,7 +425,7 @@ StScrollBar StButton#vhandle:active {
     background-color: black;
     font-weight: bold;
     height: 1.86em;
-    transition-duration: 250;
+    transition-duration: 250ms;
 }
 
 #panel.lock-screen {
@@ -508,7 +508,7 @@ StScrollBar StButton#vhandle:active {
     -minimum-hpadding: 6px;
     font-weight: bold;
     color: #ccc;
-    transition-duration: 100;
+    transition-duration: 100ms;
 }
 
 #panel.unlock-screen .panel-button,
@@ -922,7 +922,7 @@ StScrollBar StButton#vhandle:active {
     border-radius: 4px;
     padding: 3px;
     border: 1px rgba(0,0,0,0);
-    transition-duration: 100;
+    transition-duration: 100ms;
     text-align: center;
 }
 
@@ -939,7 +939,7 @@ StScrollBar StButton#vhandle:active {
 .grid-search-result:hover .overview-icon {
     background-color: rgba(255,255,255,0.1);
     text-shadow: black 0px 2px 2px;
-    transition-duration: 100;
+    transition-duration: 100ms;
     color:white;
 }
 
@@ -961,13 +961,13 @@ StScrollBar StButton#vhandle:active {
     background-gradient-direction: vertical;
     border-radius: 4px;
     box-shadow: inset 0px 1px 2px 0px rgba(0, 0, 0, 1);
-    transition-duration: 100;
+    transition-duration: 100ms;
 }
 
 .show-apps:checked .show-apps-icon,
 .show-apps:focus .show-apps-icon {
     color: white;
-    transition-duration: 100;
+    transition-duration: 100ms;
 }
 
 .app-well-app:focus > .overview-icon,
@@ -1006,7 +1006,7 @@ StScrollBar StButton#vhandle:active {
     -minimum-hpadding: 6px;
     font-weight: bold;
     color: #ccc;
-    transition-duration: 100;
+    transition-duration: 100ms;
     padding-left: .3em;
     padding-right: .3em;
 }
@@ -1309,7 +1309,8 @@ StScrollBar StButton#vhandle:active {
 #message-tray {
     background: #2e3436 url(message-tray-background.png);
     background-repeat: repeat;
-    transition-duration: 250;
+    transition-duration: 250ms;
+    height: 72px;
 }
 
 #message-tray:keyboard {
@@ -1579,7 +1580,7 @@ StScrollBar StButton#vhandle:active {
 .summary-source {
     border-radius: 4px;
     padding: 0 6px 0 6px;
-    transition-duration: 100;
+    transition-duration: 100ms;
 }
 
 .summary-source-counter {
index 694c496788e58b7efbb26537261378f646b4608d..dc3fcc25e7b58bafce3110ad98c956847b6c84c7 100644 (file)
@@ -770,6 +770,72 @@ st_theme_node_lookup_double (StThemeNode *node,
   return result;
 }
 
+/**
+ * st_theme_node_lookup_time:
+ * @node: a #StThemeNode
+ * @property_name: The name of the time property
+ * @inherit: if %TRUE, if a value is not found for the property on the
+ *   node, then it will be looked up on the parent node, and then on the
+ *   parent's parent, and so forth. Note that if the property has a
+ *   value of 'inherit' it will be inherited even if %FALSE is passed
+ *   in for @inherit; this only affects the default behavior for inheritance.
+ * @value: (out): location to store the value that was determined.
+ *   If the property is not found, the value in this location
+ *   will not be changed.
+ *
+ * Generically looks up a property containing a single time value,
+ *  which is converted to milliseconds.
+ *
+ * Return value: %TRUE if the property was found in the properties for this
+ *  theme node (or in the properties of parent nodes when inheriting.)
+ */
+gboolean
+st_theme_node_lookup_time (StThemeNode *node,
+                           const char  *property_name,
+                           gboolean     inherit,
+                           double      *value)
+{
+  gboolean result = FALSE;
+  int i;
+
+  ensure_properties (node);
+
+  for (i = node->n_properties - 1; i >= 0; i--)
+    {
+      CRDeclaration *decl = node->properties[i];
+
+      if (strcmp (decl->property->stryng->str, property_name) == 0)
+        {
+          CRTerm *term = decl->value;
+
+          if (term->type != TERM_NUMBER)
+            continue;
+
+          switch (term->content.num->type)
+            {
+            case NUM_TIME_S:
+              *value = 1000 * term->content.num->val;
+              result = TRUE;
+              break;
+            case NUM_TIME_MS:
+              *value = term->content.num->val;
+              result = TRUE;
+              break;
+            default:
+              ;
+            }
+
+          if (result)
+            break;
+        }
+    }
+
+  if (!result && inherit && node->parent_node)
+    result = st_theme_node_lookup_time (node->parent_node, property_name, inherit, value);
+
+  return result;
+}
+
 /**
  * st_theme_node_get_double:
  * @node: a #StThemeNode
@@ -2063,7 +2129,7 @@ st_theme_node_get_transition_duration (StThemeNode *node)
   if (node->transition_duration > -1)
     return st_slow_down_factor * node->transition_duration;
 
-  st_theme_node_lookup_double (node, "transition-duration", FALSE, &value);
+  st_theme_node_lookup_time (node, "transition-duration", FALSE, &value);
 
   node->transition_duration = (int)value;
 
index 120cef898fce6ce6faeb25a13c4a0d924c94be68..98da358ba3c90bb8420c21f391e924978ada986c 100644 (file)
@@ -134,6 +134,10 @@ gboolean st_theme_node_lookup_length (StThemeNode *node,
                                       const char  *property_name,
                                       gboolean     inherit,
                                       gdouble     *length);
+gboolean st_theme_node_lookup_time   (StThemeNode *node,
+                                      const char  *property_name,
+                                      gboolean     inherit,
+                                      gdouble     *value);
 gboolean st_theme_node_lookup_shadow (StThemeNode  *node,
                                       const char   *property_name,
                                       gboolean      inherit,